<template>
  <h1>猜数字练习</h1>
  <input  type="number" v-model="ng">
  <button @click="guess">猜一猜</button>
  <p>{{boo}}</p>
</template>

<script setup>
import {ref} from "vue";

const num = ref(parseInt(Math.random()*100)+1);
const ng = ref('')
const boo = ref('')
const guess = () =>{
  const guessnum = parseInt(ng.value,10);
  console.log(guessnum);
  if (guessnum<num.value){
    boo.value = '猜小了';
  }
  if(guessnum>num.value){
    boo.value='猜大了';
  }
  if (guessnum===num.value){
    boo.value = '猜对了';
  }
}
</script>

<style scoped>

</style>